home *** CD-ROM | disk | FTP | other *** search
/ Turnbull China Bikeride / Turnbull China Bikeride - Disc 2.iso / STUTTGART / LANG / C / LIB / UNIXLIB37B / !UnixLib37 / src / c / strtok < prev    next >
Text File  |  1996-11-09  |  879b  |  45 lines

  1. /****************************************************************************
  2.  *
  3.  * $Source: /unixb/home/unixlib/source/unixlib37/src/c/RCS/strtok,v $
  4.  * $Date: 1996/10/30 21:58:59 $
  5.  * $Revision: 1.2 $
  6.  * $State: Rel $
  7.  * $Author: unixlib $
  8.  *
  9.  * $Log: strtok,v $
  10.  * Revision 1.2  1996/10/30 21:58:59  unixlib
  11.  * Massive changes made by Nick Burret and Peter Burwood.
  12.  *
  13.  * Revision 1.1  1996/04/19 21:26:42  simon
  14.  * Initial revision
  15.  *
  16.  ***************************************************************************/
  17.  
  18. static const char rcs_id[] = "$Id: strtok,v 1.2 1996/10/30 21:58:59 unixlib Rel $";
  19.  
  20. #include <string.h>
  21.  
  22. char *
  23. strtok (register char *s1, register const char *s2)
  24.  
  25. {
  26.   static char *s;
  27.  
  28.   if (!s1)
  29.     {
  30.       if (!s)
  31.     return (0);
  32.       else
  33.     s1 = s;
  34.     }
  35.  
  36.   s1 += strspn (s1, s2);
  37.  
  38.   s = strpbrk (s1, s2);
  39.  
  40.   if (s)
  41.     *s++ = 0;
  42.  
  43.   return *s1 ? s1 : NULL;
  44. }
  45.